<template>
    <div class="menu">
        <el-menu
            class="el-menu"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            :default-active="defaultActive"
            @open="handleOpen"
            @close="handleClose"
            @select="onSelect"
        >
            <el-menu-item class="menu-title" index="guide">
                <span slot="title">云开发配置平台</span>
            </el-menu-item>

            <el-menu-item index="home">
                <i class="el-icon-menu"></i>
                <span slot="title">首页配置</span>
            </el-menu-item>

            <el-menu-item index="article">
                <i class="el-icon-menu"></i>
                <span slot="title">文章管理</span>
            </el-menu-item>

            <el-menu-item index="video">
                <i class="el-icon-menu"></i>
                <span slot="title">视频管理</span>
            </el-menu-item>

            <el-menu-item index="setting">
                <i class="el-icon-setting"></i>
                <span slot="title">菜单设置</span>
            </el-menu-item>
        </el-menu>
    </div>
</template>

<script>
export default {
    data() {
        return {
            defaultActive: "home",
            isRouter: true
        };
    },
    methods: {
        handleOpen(key, keyPath) {
            console.log(key, keyPath);
        },
        handleClose(key, keyPath) {
            console.log(key, keyPath);
        },
        onSelect(index) {
            const { app, namespace } = this.$route.params;
            if (namespace === index) {
                return;
            }
            this.$router.push({
                path: `/${app}/${index}`
            });
        }
    }
};
</script>

<style scoped lang="less">
.menu {
    font-size: 16px;
    height: 100vh;

    > .el-menu {
        height: 100%;
    }

    .menu-title {
        text-align: center;
        font-size: 20px;
    }
}
</style>
